package com.qf.service.Impl;

import com.github.pagehelper.PageHelper;
import com.qf.dao.Sys_userDao;
import com.qf.pojo.Sys_user;
import com.qf.service.Sys_userService;
import com.qf.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

public class Sys_userServiceImpl implements Sys_userService {

    @Autowired
    private Sys_userDao sys_userDao;


    /**
     * 登录
     * @param sys_user
     * @return
     */
    @Override
    public Sys_user loginfor(Sys_user sys_user) {

        Sys_user c = sys_userDao.findByNameAndPwd(sys_user);
        System.out.println(c);
        return c;
    }


    /**
     * 查询全部
     * @return
     */
    @Override
    public List<Sys_user> findCarUser() {
        List<Sys_user> allCarUser = sys_userDao.findAllCarUser();

        return allCarUser;
    }


    /**
     * 注册用户
     * @param sys_user
     */
    @Override
    public boolean registerfor(Sys_user sys_user) {

        Sys_user car = sys_userDao.findByNameAndPwd(sys_user);
        System.out.println("注册时查询是否存在");
        if(car==null){

            sys_userDao.addUser(sys_user);
            System.out.println("添加成功");
            return true;
        }else {
            return false;
        }
    }


    /**
     * 删除用户
     * @param id
     * @return
     */
    @Override
    public boolean deleteUserById(int id) {

        try{
            sys_userDao.deleteUserInfo(id);
            return  true;
        }catch (Exception ex){

        }


        return false;
    }


    /**
     * id查询用户
     * @param id
     * @return
     */
    @Override
    public Sys_user findById(int id) {

        Sys_user user=sys_userDao.getUserInfoByid(id);

        return user;
    }




    /**
     * 修改用户
     * @param sys_user
     * @return
     */
    @Override
    public void Userupdate(Sys_user sys_user) {
        sys_userDao.Userupdate(sys_user);

    }


    /**
     * 用户信息修改
     * @param sys_user
     */
    @Override
    public void update(Sys_user sys_user) {

        sys_userDao.updateByPrimaryKeySelective(sys_user);
    }



}
